/**
 * 
 */
package com.tiduyun.data.exchange.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.http.Header;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;

/**
 * @author wuzheng@tiduyun.com
 *
 */
public class HttpClientUtils {

    public static List<NameValuePair> nameValuePairsOf(String n1, String v1) {
        return list(p(n1, v1));
    }

    public static List<NameValuePair> nameValuePairsOf(String n1, String v1, String n2, String v2) {
        return list(p(n1, v1), p(n2, v2));
    }

    public static List<NameValuePair> nameValuePairsOf(String n1, String v1, String n2, String v2, String n3, String v3) {
        return list(p(n1, v1), p(n2, v2), p(n3, v3));
    }

    public static List<NameValuePair> nameValuePairsOf(String n1, String v1, String n2, String v2, String n3, String v3,
            String n4, String v4) {
        return list(p(n1, v1), p(n2, v2), p(n3, v3), p(n4, v4));
    }

    public static List<NameValuePair> nameValuePairsOf(String n1, String v1, String n2, String v2, String n3, String v3,
            String n4, String v4, String n5, String v5) {
        return list(p(n1, v1), p(n2, v2), p(n3, v3), p(n4, v4), p(n5, v5));
    }

    public static NameValuePair p(String n, String v) {
        return new BasicNameValuePair(n, v);
    }

    public static List<Header> headersOf(String n1, String v1) {
        return list(h(n1, v1));
    }

    public static List<Header> headersOf(String n1, String v1, String n2, String v2) {
        return list(h(n1, v1), h(n2, v2));
    }

    public static List<Header> headersOf(String n1, String v1, String n2, String v2, String n3, String v3) {
        return list(h(n1, v1), h(n2, v2), h(n3, v3));
    }

    public static List<Header> headersOf(String n1, String v1, String n2, String v2, String n3, String v3, String n4, String v4) {
        return list(h(n1, v1), h(n2, v2), h(n3, v3), h(n4, v4));
    }

    public static List<Header> headersOf(String n1, String v1, String n2, String v2, String n3, String v3, String n4, String v4,
            String n5, String v5) {
        return list(h(n1, v1), h(n2, v2), h(n3, v3), h(n4, v4), h(n5, v5));
    }

    public static Header h(String n, String v) {
        return new BasicHeader(n, v);
    }

    private static List<NameValuePair> list(NameValuePair... pairs) {
        return new ArrayList<>(Arrays.asList(pairs));
    }

    private static List<Header> list(Header... headers) {
        return new ArrayList<>(Arrays.asList(headers));
    }

}
